﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MyStore.Products
{
    public class ProductService : IProductService
    {
        private readonly IProductRepository repository;

        public ProductService(IProductRepository repository)
        {
            if (repository == null)
                throw new ArgumentNullException("repository");
            this.repository = repository;
        }

        #region IProductService 成员

        public void AutoOnline(string code)
        {
            throw new NotImplementedException();
        }

        const int MAX_SIZE = 100;
        public IList<Product> GetNewProduct(int index, int size)
        {
            if (index < 0 || size < 0 || size > MAX_SIZE)
                return new List<Product>();
            return repository.GetNewProduct(index, size);

        }

        #endregion
    }
}
